<?php

/**
 * @author Eureka
 */
class Collections extends CActiveRecord
{

	public static function model($className = __CLASS__)
	{
		return parent::model($className);
	}

	public function tableName()
	{
		return 'collections';
	}

	public function getPagination($shop_id)
	{
		$criteria = new CDbCriteria();
		$criteria->addCondition('shop_id= :shop_id');
		$criteria->params = array(':shop_id' => $shop_id);

		$item_count = Collections::model()->count($criteria);
		$page_size = 1;

		$pages = new CPagination($item_count);
		$pages->setPageSize($page_size);
		$pages->applyLimit($criteria);
		
		return $pages;
	}

	public function relations()
	{
		return array(
			'shops' => array(
				self::BELONGS_TO, 'Shops', 'shop_id'
			),
		);
	}
}